package com.nantai.jiafang.nantaijiafang.deviceManager.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.nantai.jiafang.nantaijiafang.R;
import com.nantai.jiafang.nantaijiafang.deviceManager.bean.Device.PutRecordBean;

import java.util.List;

/**
 * Created by xxfreedom on 2017/2/12.
 */

public class PutRecordAdapter extends BaseAdapter {
    private List<PutRecordBean> recordList;
    private LayoutInflater inflater;
    public PutRecordAdapter() {}

    public PutRecordAdapter(List<PutRecordBean> recordList, Context context) {
        this.recordList = recordList;
        this.inflater=LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return recordList==null?0:recordList.size();
    }

    @Override
    public PutRecordBean getItem(int position) {
        return recordList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //加载布局为一个视图
        View view=inflater.inflate(R.layout.put_record_item,null);
        PutRecordBean recordBean=getItem(position);
        TextView tv_operate= (TextView) view.findViewById(R.id.operate_tx);
        TextView tv_time= (TextView) view.findViewById(R.id.time_tx);
        TextView tv_person= (TextView) view.findViewById(R.id.person_tx);
        TextView tv_place= (TextView) view.findViewById(R.id.place_tx);
        String operate="";
        switch (recordBean.getOperate_type())
        {
            case 1:
            {
                operate="采购入库";
            }
            break;
            case 2:
            {
                operate="维修入库";
            }
            break;

            case 3:
            {
                operate="调拨入库";
            }
            break;
            case 4:
            {
                operate="维修出库";
            }
            break;
            case 5:
            {
                operate="销售出库";
            }
            break;
            case 6:
            {
                operate="报废出库";
            }
            break;
        }
        tv_operate.setText("操作类型: "+operate);
        tv_time.setText("操作时间: "+recordBean.getCreate_time());
        tv_person.setText("操作人员: "+recordBean.getName());
        tv_place.setText("目标地点: "+recordBean.getPlace_name());
        return view;
    }
}
